// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import DataManager from "../core/DataManager";

cc.Class({
    extends: cc.Component,

    properties: {
        icon: {
            default: null,
            type: cc.Sprite,
            tooltip: '拼图按钮图片'
        },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    init(data) {
        if (!data) {
            return;
        }
        this.node.targetData = data;
        this.icon.spriteFrame = DataManager.GameConfig[DataManager.currLevel][this.node.targetData.outline];
        let posArr = this.node.targetData.pos.split(',');
        this.node.zIndex = this.node.targetData.zIndex;
        this.node.setPosition(posArr[0],posArr[1])
    },

    setPut(param){
        this.icon.spriteFrame = param;
    }

    // update (dt) {},
});
